package cn.xm.lingshi.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.xm.lingshi.pojo.Shop;
import cn.xm.lingshi.pojo.Type;
import cn.xm.lingshi.service.ShopService;
import cn.xm.lingshi.service.impl.ShopServiceImpl;

import com.alibaba.fastjson.JSON;
/**
 * 类型
 * @author 魏魁
 *
 */
public class TypeServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		// 接收请求数据
		request.setCharacterEncoding("UTF-8");
		ShopService service=new ShopServiceImpl();
		List<Type> list=service.getType();
		//响应JSON格式的数据
		out.print(JSON.toJSONString(list));
		out.flush();
		out.close();
	}

	public void init() throws ServletException {

	}

}
